package com.netease.pris.activity.view;

import android.content.Context;
import android.content.res.Resources;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.Adapter;
import android.widget.FrameLayout;
import android.widget.Scroller;
import java.util.LinkedList;

public class FlingGallery extends FrameLayout
{
  private static final int M = 16;
  private static final String b = "FlingGallery";
  private static final boolean c = false;
  private static final int g = 100;
  private ap A;
  private i B;
  private r C;
  private ao D;
  private ca E;
  private bs F = null;
  private s G = null;
  private boolean H = false;
  private int I = 0;
  private boolean J;
  private LinkedList K = new LinkedList();
  private Scroller L;
  private int N = 0;
  private int O = 0;
  private Handler P = new bv(this);
  private float Q;
  private float R;
  private boolean S = true;
  private boolean T = false;
  private boolean U = false;
  private boolean V;
  private boolean W;
  private int X;
  private int Y;
  private int Z;
  protected GestureDetector a;
  private int aa;
  private Runnable ab = new bu(this);
  private int d = 60;
  private int e = 300;
  private int f = 250;
  private int h = 0;
  private int i = 500;
  private float j = 0.7F;
  private boolean k = false;
  private int l = 0;
  private int m = 0;
  private boolean n = false;
  private boolean o = false;
  private boolean p = false;
  private float q = 0.0F;
  private long r = 0L;
  private int s = 0;
  private int t = 0;
  private int u = 0;
  private Context v;
  private Adapter w;
  private a[] x;
  private bl y;
  private Interpolator z;

  public FlingGallery(Context paramContext)
  {
    this(paramContext, null);
  }

  public FlingGallery(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    a(paramContext);
  }

  private int a(int paramInt1, int paramInt2)
  {
    int i1 = this.l + this.h;
    if (paramInt1 == h(paramInt2));
    while (true)
    {
      return i1;
      if (paramInt1 == i(paramInt2))
      {
        i1 *= -1;
        continue;
      }
      i1 = 0;
    }
  }

  private void a(Context paramContext)
  {
    this.v = paramContext;
    this.w = null;
    this.x = new a[3];
    this.x[0] = new a(this, 0, this);
    this.x[1] = new a(this, 1, this);
    this.x[2] = new a(this, 2, this);
    this.y = new bl(this);
    this.a = new GestureDetector(new bi(this, null));
    this.z = AnimationUtils.loadInterpolator(this.v, 17432582);
    this.I = ViewConfiguration.get(paramContext).getScaledTouchSlop();
    this.L = new Scroller(paramContext, new DecelerateInterpolator());
    float f1 = paramContext.getResources().getDisplayMetrics().density;
    this.N = (int)(f1 * this.d);
    this.O = (int)(0.5D + f1 * this.e);
  }

  private void c()
  {
    int i1;
    int i2;
    if (this.aa > 0)
    {
      i1 = i(this.X);
      i2 = g(this.t);
    }
    for (int i3 = h(this.X); ; i3 = i(this.X))
    {
      this.x[this.X].c(this.X);
      if (this.x[i1].b() != i2)
        this.x[i1].e(i2);
      if (i1 != i3)
        this.x[i3].c(this.X);
      this.x[0].a(this.Z, 0, this.X);
      this.x[1].a(this.Z, 0, this.X);
      this.x[2].a(this.Z, 0, this.X);
      this.x[0].d(this.X);
      this.x[1].d(this.X);
      this.x[2].d(this.X);
      this.V = false;
      if (this.A != null)
        this.A.a(this.t);
      if ((!this.W) && (this.aa > 0) && (this.B != null) && (this.t == h()))
        this.B.a();
      if ((!this.W) && (this.aa < 0) && (this.B != null) && (this.t == i()))
        this.B.b();
      if (this.P != null)
        this.P.sendEmptyMessage(100);
      return;
      i1 = h(this.X);
      i2 = f(this.t);
    }
  }

  private int f(int paramInt)
  {
    int i1 = paramInt - 1;
    if (i1 < h())
      if (this.k != true)
        break label27;
    label27: for (i1 = i(); ; i1 = -1 + h())
      return i1;
  }

  private int g(int paramInt)
  {
    int i1 = paramInt + 1;
    if (i1 > i())
      if (this.k != true)
        break label27;
    label27: for (i1 = h(); ; i1 = 1 + i())
      return i1;
  }

  private int h(int paramInt)
  {
    if (paramInt == 0);
    for (int i1 = 2; ; i1 = paramInt - 1)
      return i1;
  }

  private int i(int paramInt)
  {
    if (paramInt == 2);
    for (int i1 = 0; ; i1 = paramInt + 1)
      return i1;
  }

  public void a()
  {
    this.s = 1;
    p();
  }

  public void a(float paramFloat)
  {
    this.j = paramFloat;
  }

  public void a(int paramInt)
  {
    this.h = paramInt;
  }

  public void a(Adapter paramAdapter, int paramInt)
  {
    this.w = paramAdapter;
    this.t = paramInt;
    this.x[this.u].e(this.t);
    this.x[i(this.u)].e(g(this.t));
    this.x[h(this.u)].e(f(this.t));
    this.x[this.u].a(0, 0, this.u);
    this.x[i(this.u)].a(0, 0, this.u);
    this.x[h(this.u)].a(0, 0, this.u);
  }

  public void a(ao paramao)
  {
    this.D = paramao;
  }

  public void a(ap paramap)
  {
    this.A = paramap;
  }

  public void a(bs parambs)
  {
    this.F = parambs;
  }

  public void a(ca paramca)
  {
    this.E = paramca;
  }

  public void a(i parami)
  {
    this.B = parami;
  }

  public void a(r paramr)
  {
    this.C = paramr;
  }

  public void a(s params)
  {
    this.G = params;
  }

  public void a(String paramString)
  {
    if (this.x[0].a(paramString));
    while (true)
    {
      return;
      if (!this.x[1].a(paramString))
      {
        this.x[2].a(paramString);
        continue;
      }
    }
  }

  public boolean a(int paramInt1, int paramInt2, Object paramObject)
  {
    if ((paramInt1 < 0) || (paramInt1 > 2))
      paramInt1 = this.u;
    a locala = this.x[paramInt1];
    if (locala == null);
    for (boolean bool = false; ; bool = locala.b(paramInt1, paramInt2, paramObject))
      return bool;
  }

  protected boolean a(MotionEvent paramMotionEvent)
  {
    int i1 = 1;
    float f1 = paramMotionEvent.getX();
    float f2 = paramMotionEvent.getY();
    int i2 = (int)Math.abs(f1 - this.Q);
    int i3 = (int)Math.abs(f2 - this.R);
    int i4;
    if (i2 > this.I)
    {
      i4 = i1;
      if ((i4 == 0) || (i3 > i2))
        break label70;
    }
    while (true)
    {
      return i1;
      i4 = 0;
      break;
      label70: i1 = 0;
    }
  }

  protected boolean a(MotionEvent paramMotionEvent1, MotionEvent paramMotionEvent2, float paramFloat1, float paramFloat2)
  {
    return false;
  }

  public Object b(int paramInt1, int paramInt2, Object paramObject)
  {
    if ((paramInt1 < 0) || (paramInt1 > 2))
      paramInt1 = this.u;
    a locala = this.x[paramInt1];
    if (locala == null);
    for (Object localObject = null; ; localObject = locala.a(paramInt1, paramInt2, paramObject))
      return localObject;
  }

  public void b()
  {
    this.s = -1;
    p();
  }

  public void b(int paramInt)
  {
    this.f = paramInt;
  }

  public void b(String paramString)
  {
    if (this.x[0].b(paramString));
    while (true)
    {
      return;
      if (!this.x[1].b(paramString))
      {
        this.x[2].b(paramString);
        continue;
      }
    }
  }

  public void b(boolean paramBoolean)
  {
    this.H = paramBoolean;
  }

  public boolean b(MotionEvent paramMotionEvent)
  {
    boolean bool = false;
    if (this.a != null)
      bool = this.a.onTouchEvent(paramMotionEvent);
    if ((paramMotionEvent.getAction() == 1) && ((this.n) || (this.o) || (this.p)))
    {
      q();
      p();
    }
    return bool;
  }

  public void c(int paramInt)
  {
    this.i = paramInt;
  }

  public void c(boolean paramBoolean)
  {
    if (this.k != paramBoolean)
    {
      this.k = paramBoolean;
      if (this.t == h())
        this.x[h(this.u)].e(f(this.t));
      if (this.t == i())
        this.x[i(this.u)].e(g(this.t));
    }
  }

  public void d(int paramInt)
  {
    if (this.t == paramInt);
    while (true)
    {
      return;
      this.t = paramInt;
      this.u = 0;
      this.x[0].e(this.t);
      this.x[1].e(g(this.t));
      this.x[2].e(f(this.t));
      this.x[0].a(0, 0, this.u);
      this.x[1].a(0, 0, this.u);
      this.x[2].a(0, 0, this.u);
    }
  }

  public void d(boolean paramBoolean)
  {
    this.U = paramBoolean;
  }

  public void e(int paramInt)
  {
    int i1 = -1;
    this.J = true;
    this.W = false;
    if (this.X != paramInt)
      if (this.V == true)
        if (paramInt != h(this.X))
          break label203;
    label203: for (int i2 = 1; ; i2 = i1)
    {
      if (this.aa < 0)
        i1 = 1;
      if (i1 == i2)
      {
        this.x[0].a(this.Z, 0, this.X);
        this.x[1].a(this.Z, 0, this.X);
        this.x[2].a(this.Z, 0, this.X);
      }
      this.X = paramInt;
      this.W = true;
      this.Y = this.x[this.X].c();
      this.Z = a(this.X, this.X);
      this.aa = (this.Z - this.Y);
      this.V = true;
      this.L.startScroll(this.Y, 0, this.aa, 0);
      this.P.post(this.ab);
      return;
    }
  }

  public a[] e()
  {
    return this.x;
  }

  public void f()
  {
    if (this.x != null)
    {
      int i1 = this.x.length;
      for (int i2 = 0; i2 < i1; i2++)
      {
        this.x[i2].a();
        this.x[i2] = null;
      }
    }
    if (this.K != null)
      this.K.clear();
    if (this.P != null)
    {
      this.P.removeMessages(100);
      this.P.removeCallbacks(null);
      this.P = null;
    }
    this.y = null;
    this.a = null;
    this.w = null;
    this.v = null;
  }

  public int g()
  {
    if (this.w == null);
    for (int i1 = 0; ; i1 = this.w.getCount())
      return i1;
  }

  public int h()
  {
    return 0;
  }

  public int i()
  {
    if (g() == 0);
    for (int i1 = 0; ; i1 = -1 + g())
      return i1;
  }

  public int j()
  {
    return this.l;
  }

  public int k()
  {
    return this.m;
  }

  public int l()
  {
    return this.t;
  }

  public int m()
  {
    return this.u;
  }

  public void n()
  {
    synchronized (this.K)
    {
      if (this.J)
      {
        this.K.add(new Integer(-1));
        return;
      }
      a();
    }
  }

  public void o()
  {
    synchronized (this.K)
    {
      if (this.J)
      {
        this.K.add(new Integer(1));
        return;
      }
      b();
    }
  }

  public boolean onInterceptTouchEvent(MotionEvent paramMotionEvent)
  {
    boolean bool = false;
    if (this.U);
    while (true)
    {
      return bool;
      int i1 = com.netease.imageex.a.a.a(paramMotionEvent).b();
      if ((!this.o) && (i1 == com.netease.imageex.a.a.c))
      {
        this.T = true;
        MotionEvent localMotionEvent2 = MotionEvent.obtain(paramMotionEvent);
        localMotionEvent2.setAction(3);
        this.a.onTouchEvent(localMotionEvent2);
        continue;
      }
      if ((i1 == 1) && (this.T))
      {
        this.T = false;
        continue;
      }
      if (this.T)
        continue;
      switch (i1)
      {
      default:
        break;
      case 0:
        bool = this.J;
        if (this.J)
          continue;
        this.Q = paramMotionEvent.getX();
        this.R = paramMotionEvent.getY();
        this.S = true;
        if (this.a == null)
          continue;
        this.a.onTouchEvent(paramMotionEvent);
        break;
      case 2:
        bool = a(paramMotionEvent);
        if (bool)
          continue;
        bool = this.a.onTouchEvent(paramMotionEvent);
        break;
      case 1:
      case 3:
        bool = this.J;
        if (bool)
          continue;
        MotionEvent localMotionEvent1 = MotionEvent.obtain(paramMotionEvent);
        if (this.a == null)
          continue;
        this.a.onTouchEvent(localMotionEvent1);
      }
    }
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    this.l = (paramInt3 - paramInt1);
    this.m = (paramInt4 - paramInt2);
    if ((paramBoolean == true) && (this.x != null))
    {
      if (this.x[0] != null)
      {
        this.x[0].a(this.m);
        this.x[0].a(0, 0, this.u);
      }
      if (this.x[1] != null)
      {
        this.x[1].a(this.m);
        this.x[1].a(0, 0, this.u);
      }
      if (this.x[2] != null)
      {
        this.x[2].a(this.m);
        this.x[2].a(0, 0, this.u);
      }
    }
    super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    if (this.J);
    for (boolean bool = true; ; bool = b(paramMotionEvent))
      return bool;
  }

  void p()
  {
    int i1 = this.u;
    this.n = false;
    this.o = false;
    this.p = false;
    if (this.s > 0)
      if ((this.t > h()) || (this.k == true))
      {
        i1 = h(this.u);
        this.t = f(this.t);
      }
    label80: label248: 
    while (true)
    {
      if (i1 != this.u)
      {
        this.u = i1;
        if (((this.x[this.u].c() != 0) || (this.s != 0)) && (this.y != null))
          e(this.u);
        this.s = 0;
      }
      while (true)
      {
        return;
        if ((this.s >= 0) || ((this.t >= i()) && (this.k != true)))
          break label248;
        i1 = i(this.u);
        this.t = g(this.t);
        break;
        if (this.B == null)
          break label80;
        if ((this.t == h()) && (this.s > 0))
        {
          this.B.a();
          this.s = 0;
          continue;
        }
        if ((this.t != i()) || (this.s >= 0))
          break label80;
        this.B.b();
        this.s = 0;
      }
    }
  }

  void q()
  {
    float f1 = this.l * this.j;
    int i1 = this.l - (int)f1;
    int i2 = this.x[this.u].c();
    if (i2 <= i1 * -1)
      this.s = 1;
    if (i2 >= i1)
      this.s = -1;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.activity.view.FlingGallery
 * JD-Core Version:    0.6.0
 */